package cn.springcloud.fix.samples.mq.consumer;

import cn.hutool.extra.mail.Mail;
import cn.springcloud.fix.samples.mq.MessageHelper;
import com.aliyun.oss.ServiceException;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MailConsumer implements BaseConsumer {

    @Override
    public void consume(Message message, Channel channel) {
        Mail mail = MessageHelper.msgToObj(message, Mail.class);
        log.info("收到消息: {}", mail.toString());

        // boolean success = mailUtil.send(mail);
        // if (!success) {
        //     throw new ServiceException("send mail error");
        // }
    }
}
